package month_1;

/**
 * @author： pang-yun
 * @date： 2022-01-06 20:28
 * 功能目的 ：用于
 */

public class FindStr_1 {
    public static void main(String[] args) {
        String source = "a";
        String target = "a";
        int i = strStr(source, target);
        System.out.println(i);
    }


    public static int strStr(String source, String target) {
        char[] sourceArray = source.toCharArray();
        char[] targetArray = target.toCharArray();
        if ( targetArray.length==0){
            return 0;
        }
        for (int i = 0; i < sourceArray.length ; i++) {
            int answer = i;
            int index = i;
            int j = 0;
            while (index < sourceArray.length && j < targetArray.length && sourceArray[index] == targetArray[j]) {
                index++;
                j++;
            }
            if (j == targetArray.length) {
                return i;
            }
        }
        return -1;
    }
}
